// TVMGUISimulatorDlg.h : header file
//

#pragma once
#include "../tvm/tvm_utility.h"
// CTVMGUISimulatorDlg dialog
class CTVMGUISimulatorDlg : public CDialog
{
// Construction
public:
	CTVMGUISimulatorDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_TVMGUISIMULATOR_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

public:
	void OutputToTextBox(const char* msg);
	void SendKey(uint32 key);
// Implementation
protected:
	enum
	{
		TGS_BTN_NUM		=	5,
		TGS_BTN_RADIUS	=	39	,
		TGS_REMOTE_BMP_X_OFFSET	=	11,
		TGS_REMOTE_BMP_Y_OFFSET	=	11,
		TGS_ID_TIMER	= 1111
	};

	enum TGSColor
	{
		TGS_COLOR_WHITE	= RGB(254, 254, 254),
		TGS_COLOR_TATA	=	RGB(99, 183, 220)
	};

	enum TGSKey
	{
		TGS_KEY_PLAY,
		TGS_KEY_PAUSE,
		TGS_KEY_PREV,
		TGS_KEY_NEXT,
		TGS_KEY_VOL_UP,
		TGS_KEY_VOL_DOWN,
		TGS_KEY_NONE
	};

	enum TGSButton
	{
		TGS_BTN_PLAY_PAUSE,
		TGS_BTN_PREV,
		TGS_BTN_NEXT,
		TGS_BTN_VOL_UP,
		TGS_BTN_VOL_DOWN,
		TGS_BTN_NONE
	};

	enum TGSTVMState
	{
		TGS_TVM_STATE_RUNNING,
		TGS_TVM_STATE_STOPPED
	};

	HICON m_hIcon;

	CBrush m_whiteBrush;
	CBrush m_blueBrush;
	HCURSOR m_handCursor;
	HCURSOR m_arrowCursor;
	static POINT m_btnCenter[ TGS_BTN_NUM ];

	//TVM related variable
	uint32 m_period;		//the period
	uint8*				m_code;//the code buffer
	uint32				m_autoLog;	//the auto log flag
	CBitmap			m_remoteBmp;
	TGSTVMState				m_tvmState;

	void DrawButton(TGSButton button);
	void RestoreRemoteBmp();
	BOOL TVMInit(const _TCHAR* tataFilename);
	void TVMClean();
	void Run();
	void Stop();
	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedExitBtn();
	afx_msg void OnBnClickedBrowseBtn();
	afx_msg void OnBnClickedRunTvmBtn();
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
};
